# all library source file
AUX_SOURCE_DIRECTORY(. LIBSRC)

# for windows
# add_definitions("-DTAOISM_API_EXPORTS")
# add_definitions("-DTAOISM_STATIC")

# head file directory
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/common)
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/lib3rd/include)

# create shared library
ADD_LIBRARY(taoism_shared SHARED ${LIBSRC})
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
    SET_TARGET_PROPERTIES(taoism_shared PROPERTIES OUTPUT_NAME "taoism")
elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
    SET_TARGET_PROPERTIES(taoism_shared PROPERTIES OUTPUT_NAME "libtaoism")
endif ()

# create static library
ADD_LIBRARY(taoism_static STATIC ${LIBSRC})
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
    SET_TARGET_PROPERTIES(taoism_static PROPERTIES OUTPUT_NAME "taoism")
elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
    SET_TARGET_PROPERTIES(taoism_static PROPERTIES OUTPUT_NAME "libtaoism")
endif ()

# install 
# copy all head files
set(INSTALL_DIR ${PROJECT_SOURCE_DIR}/libsrc/install)
file(GLOB HEAD_FILES ./*.h)
INSTALL(FILES ${HEAD_FILES} DESTINATION ${INSTALL_DIR}/include)

# copy library files
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
INSTALL(TARGETS taoism_shared taoism_static
        LIBRARY DESTINATION ${INSTALL_DIR}/linux
        ARCHIVE DESTINATION ${INSTALL_DIR}/linux)
elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
INSTALL(TARGETS taoism_shared taoism_static
        LIBRARY DESTINATION ${INSTALL_DIR}/windows
        ARCHIVE DESTINATION ${INSTALL_DIR}/windows)
endif()
